﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class UserWork_LeaveRegister : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
     
    }
    protected void bnSave_ServerClick(object sender, EventArgs e)
    {
        if (this.TextBox1.Text.Trim() == "" || this.TextBox2.Text.Trim() == "")
        {
            Response.Write("<script>alert('请选择时间！')</script>");
        }
        else
        {
            try
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Connection"]);
                con.Open();
                string Fdate = this.TextBox1.Text.ToString().Trim();
                string Tdate = this.TextBox2.Text.ToString().Trim();
                string content = this.TextBox5.Text.ToString().Trim();
                string sql = "insert into leave values('" + Session["UserName"].ToString() + "','" + Fdate + "','" + Tdate + "','" + content + "') ";
                SqlCommand com = new SqlCommand(sql, con);
                com.ExecuteNonQuery();
                Response.Write("<script>alert('登记成功！！');window.location.href='LeaveList.aspx';</script>");
                con.Close();
            }
            catch 
            {
                Response.Write("<script>alert('请填写正确资料！！')</script>");
            }
        }
    }
}
